package com.sykj.cloud.mq.demo.base;

import com.sykj.cloud.mq.demo.Constant;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import static com.sykj.cloud.mq.demo.Constant.*;
/**
 * @author Mr.will
 * @date 2021/3/4 11:08
 * @Desc 发送单项消息
 */
public class OneWayProducer {


    public static void main(String[] args) throws Exception {
        DefaultMQProducer mqProducer=new DefaultMQProducer("group01");
        mqProducer.setNamesrvAddr(Constant.SERVER_URL);
        mqProducer.start();

//        组装消息
        String body="OK Life is fucking movie";

        Message message=new Message(TOPIC_3,TAG_3,body.getBytes());
        mqProducer.sendOneway(message);

        mqProducer.shutdown();
    }
}

